feat(bundling): integrate oxc-transform for TypeScript declaration generation#35113
Open
benpsnyder wants to merge 3 commits intonrwl:masterfrom
Open
feat(bundling): integrate oxc-transform for TypeScript declaration generation#35113benpsnyder wants to merge 3 commits intonrwl:masterfrom
benpsnyder wants to merge 3 commits intonrwl:masterfrom
Conversation
✅ Deploy Preview for nx-docs canceled.
|
✅ Deploy Preview for nx-dev canceled.
|
… update dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
TypeScript declaration (
.d.ts) generation in Nx library builds relies exclusively on the TypeScript compiler (tsc), either via@rollup/plugin-typescript,rollup-plugin-typescript2, orvite-plugin-dts. This works but is significantly slower than the JavaScript compilation step, especially in large monorepos. There is no way to use faster alternatives like OXC'sisolatedDeclarationfor.d.tsemission.Expected Behavior
A new
useOxcDeclarationsoption is available across@nx/rollup,@nx/esbuild, and@nx/vitethat usesoxc-transform'sisolatedDeclaration()to generate.d.tsfiles instead oftsc. This is significantly faster and requiresisolatedDeclarations: truein the project's tsconfig.What's included
Shared core (
@nx/js):oxc-declaration-emitter.ts— standalone function that walks source files and emits.d.tsviaoxc-transform'sisolatedDeclaration(). Supports sourcemaps and@internalstripping.oxc-declarations.ts— Rollup plugin wrapper around the emitter, used by both@nx/rollupand@nx/viteoxcTransformVersionadded toversions.ts@nx/rollup:useOxcDeclarationsoption inwithNx()— when enabled with SWC/Babel compiler, skips the TypeScript plugin entirely (SWC/Babel handles JS, OXC handles declarations)oxc-transformdependency installation inensure-dependencies.ts@nx/esbuild:useOxcDeclarationsoption in the esbuild executor — runs the OXC emitter as a post-build step alongside the existingemitDeclarationOnlytsc pass (or as a replacement when enabled)@nx/vite:nxOxcDeclarationsPlugin— a Vite plugin that wraps the shared Rollup plugin for use invite.config.tsdeclarations: 'oxc'option in the configuration generatorArchitecture
Context: AnalogJS and ng-packagr
This work is motivated by the OXC ecosystem adoption tracked in our broader issue. AnalogJS 3.0-alpha already uses
oxc-transformfor declaration generation across 15+ packages. ng-packagr is also preparing for OXC-based declarations (TypeScript 6 withisolatedDeclarationslanded in ng-packagr#3259,oxc-transformis staged in ng-packagr#3252).Related Issue(s)
#35111